home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / v0_98 / aaai-named.bst < prev    next >
Text File  |  1990-10-02  |  41KB  |  1,548 lines

  1. %NAME: aaai-named.bst
  2. % BibTeX `named' style-file version 1
  3. %    for BibTeX version 0.98i or later, LaTeX version 2.09
  4. %    by Peter F. Patel-Schneider
  5. % This style is NOT guaranteed to work.  It is provided in the hope
  6. % that it will make the preparation of papers for AAAI-87 easier. 
  7. %
  8. % There are undoubtably bugs in this style.  If you make bug fixes,
  9. % improvements, etc.  please let me know.  My e-mail address is:
  10. %    pfps@spar.slb.com
  11. %
  12. % Modified from:
  13. % BibTeX standard bibliography style `alpha'
  14.     % version 0.98c for BibTeX versions 0.98i or later, LaTeX version 2.08
  15.     % Copyright (C) 1985, all rights reserved
  16.     % Copying of this file is authorized only if either
  17.     % (1) you make absolutely no changes to your copy, including name, or
  18.     % (2) if you do make changes, you name it something other than
  19.     % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst
  20.     % This restriction helps ensure that all standard styles are identical
  21. %
  22. %   Entry formatting: Similar to that recommended by Mary-Claire van Leunen
  23. %    in "A Handbook for Scholars".  Book-like titles are italicized,
  24. %    non-book titles are converted to sentence capitilization
  25. %    (and not enclosed in quotes).  Either the "open" or the "closed"
  26. %    format can be used, with the appropriate definition of
  27. %    \newblock (the name \newblock is analogous to the names \newline
  28. %    and \newpage).  The "open" format has a line break before each
  29. %    major block of an entry, and lines after the first are indented
  30. %    within blocks.  The "closed" format just runs the blocks
  31. %    together.  This file outputs a \newblock between blocks.
  32. %    It uses the closed format.
  33. %
  34. %   Citation format: [author-last-name, year]
  35. %             [author-last-name and author-last-name, year]
  36. %             [author-last-name {\em et al.}, year]
  37. %
  38. %   Reference list ordering: alphabetical by author or whatever passes
  39. %    for author in the absence of one.
  40. %
  41. % This BibTeX style has support for short (year only) citations.  This
  42. % is done by having the citations actually look like
  43. %         \citename{name-info, }year
  44. % The LaTeX style has to have the following
  45. %     \let\@internalcite\cite
  46. %     \def\cite{\def\citename##1{##1}\@internalcite}
  47. %     \def\shortcite{\def\citename##1{}\@internalcite}
  48. %     \def\@biblabel#1{\def\citename##1{##1}[#1]\hfill}
  49. % which makes \shortcite the macro for short citations.
  50.  
  51. %   History
  52. %   12/16/84    (HWT)    Original version, by Howard Trickey.
  53. %   12/23/84    (LL)    Some comments made by Leslie Lamport.
  54. %    2/12/85    (OP)    Changes based primarily on LL's comments
  55. %    1/07/85    (pfps)    Change to named style plus some enhancements.
  56. %    9/15/85    (pfps)  Added support for short (year only) citations.
  57.  
  58. % The ENTRY declaration
  59. %   Like Scribe's (according to pages 231-2 of the April '84 edition),
  60. %   but no fullauthor or editors fields because BibTeX does name handling.
  61. %   The annote field is commented out here because this isn't an annotated
  62. %   bibliography style
  63.  
  64. ENTRY {            % Fields:
  65.     address        % Publisher's address
  66. %    annote        % Long annotation used for annotated bibliographies
  67.             % (begins sentence)
  68.     author        % Name(s) of author(s), in BibTeX name format
  69.     booktitle        % Title of a book when the thing being referenced
  70.             % isn't the whole book.  For book entries, the title
  71.             % field should be used instead.
  72.     chapter        % Chapter number
  73.     edition        % Edition of a book (e.g., "second")
  74.     editor        % Name(s) of editor(s), in BibTeX name format
  75.             % If there is also an author field, then the editor
  76.             % field should be for the book or collection that the
  77.             % work appears in
  78.     howpublished    % How something strange has been published
  79.             % (begins sentence)
  80.     institution        % Sponsoring institution
  81.     journal        % Journal name (macros are provided for many)
  82.     key            % Alphabetizing (and perhaps labeling) key
  83.             % (needed when no author or editor)
  84.     location        % Location for a conference
  85.     month        % Month (macros are provided)
  86.     note        % Help in finding a reference (begins sentence)
  87.     number        % Number of a journal or technical report
  88.     organization    % Organization (sponsoring a conference)
  89.     pages        % Page number or numbers (use `--' to separate a range)
  90.     publisher        % Publisher name
  91.     school        % School name (for theses)
  92.     series        % The name of a series or set of books; an individual
  93.             % book will will also have it's own title
  94.     title        % Title
  95.     type        % Type of a Techreport (e.g., "Research Note")
  96.             % to be used instead of default "Technical Report"
  97.     volume        % Volume of a journal or multivolume work
  98.     year        % Year
  99.   }
  100.   {}            % No integer entry variables
  101.   { label extralabel }    % String entry variables used to form citation label
  102.  
  103. % Each entry function starts by calling output.bibitem, to write the
  104. % \bibitem and its arguments to the .bbl file.  Then the various fields
  105. % are formatted and printed by output or output.check.  Those functions
  106. % handle the writing of separators (commas, periods, \newblock's),
  107. % taking care not to do so when they are passed a null string.
  108. % Finally, fin.entry is called to add the final period and finish the
  109. % entry.
  110. %
  111. % A bibliographic reference is formatted into a number of `blocks':
  112. % in the open format, a block begins on a new line and subsequent
  113. % lines of the block are indented.  A block may contain more than
  114. % one sentence (well, not a grammatical sentence, but something to
  115. % be ended with a sentence ending period).  The entry functions should
  116. % call new.block whenever a block other than the first is about to be
  117. % started.  They should call new.sentence whenever a new sentence is
  118. % to be started.  The output functions will ensure that if two
  119. % new.sentence's occur without any non-null string being output between
  120. % them then there won't be two periods output.  Similarly for two
  121. % successive new.block's.
  122.  
  123. % The output routines don't write their argument immediately.
  124. % Instead, by convention, that argument is saved on the stack to be
  125. % output next time (when we'll know what separator needs to come
  126. % after it).  Meanwhile, the output routine has to pop the pending
  127. % output off the stack, append any needed separator, and write it.
  128. %
  129. % To tell which separator is needed, we maintain an output.state.
  130. % It will be one of these values:
  131. %    before.all        just after the \bibitem
  132. %    mid.sentence        in the middle of a sentence: comma needed
  133. %                    if more sentence is output
  134. %    after.sentence        just after a sentence: period needed
  135. %    after.block        just after a block (and sentence):
  136. %                    period and \newblock needed.
  137. % Note: This style (plain) doesn't use after.sentence
  138. %
  139. % VAR: output.state : INTEGER        -- state variable for output
  140. %
  141. % The output.nonnull function saves its argument (assumed to be nonnull)
  142. % on the stack, and writes the old saved value followed by any needed
  143. % separator.  The ordering of the tests is decreasing frequency of
  144. % occurrence.
  145. %
  146. % output.nonnull(s) ==
  147. %  BEGIN
  148. %    s := argument on stack
  149. %    if output.state = mid.sentence then
  150. %        write$(pop() * ", ")
  151. %          -- "pop" isn't a function: just use stack top
  152. %    else
  153. %        if output.state = after.block then
  154. %        write$(add.period$(pop()))
  155. %        newline$
  156. %        write$("\newblock ")
  157. %        else
  158. %        if output.state = before.all then
  159. %            write$(pop())
  160. %        else        -- output.state should be after.sentence
  161. %            write$(add.period$(pop()) * " ")
  162. %        fi
  163. %        fi
  164. %    fi
  165. %    push s on stack
  166. %    output.state := mid.sentence
  167. %  END
  168. %
  169. % The output function calls output.nonnull if its argument is non-null
  170. %
  171. % output(s) ==
  172. %  BEGIN
  173. %    if s <> "" then output.nonnull(s)
  174. %    fi
  175. %  END
  176. %
  177. % The output.check function calls output.nonnull if s is non-null
  178. % and warns the user that the t field shouldn't be empty (this is
  179. % because it won't be a good reference without the field;  the entry
  180. % functions try to make the formatting look reasonable even when such
  181. % fields are empty).
  182. %
  183. % output.check(t,s) ==
  184. %  BEGIN
  185. %    if s = "" then
  186. %        top$("Warning: the " * t * " shouldn't be empty in " * cite$)
  187. %    else output.nonnull(s)
  188. %    fi
  189. %  END
  190. %
  191. % The output.bibitem function writes the \bibitem for the current entry
  192. % (the label should already have been set up), and sets up the separator
  193. % state for the output functions.  And, it leaves a string on the stack
  194. % as per the output convention.
  195. %
  196. % output.bibitem ==
  197. %  BEGIN
  198. %    newline$
  199. %    write$("\bibitem[")    % for nonnumeric labels,
  200. %    write$(label)        % these three lines should be used
  201. %    write$("]{")        % instead of the following line
  202. %    write$("\bibitem{")
  203. %    write$(cite$)
  204. %    write$("}")
  205. %    push "" on stack
  206. %    output.state := before.all
  207. %  END
  208. %
  209. % The fin.entry function finishes off an entry by adding a period to the
  210. % string remaining on the stack.  If the state is still before.all
  211. % then nothing was produced for this entry, so the result will look bad,
  212. % but the user deserves it. (We don't omit the whole entry because the
  213. % entry was cited, and a bibitem is needed to define the citation label.)
  214. %
  215. % fin.entry ==
  216. %  BEGIN
  217. %    write$(add.period$(pop()))
  218. %    newline$
  219. %  END
  220. %
  221. % The new.block function prepares for a new block to be output, and
  222. % new.sentence prepares for a new sentence.
  223. %
  224. % new.block ==
  225. %  BEGIN
  226. %    if output.state <> before.all then
  227. %        output.state := after.block
  228. %    fi
  229. %  END
  230. %
  231. % new.sentence ==
  232. %  BEGIN
  233. %    if output.state <> after.block then
  234. %        if output.state <> before.all then
  235. %        output.state :=  after.sentence
  236. %        fi
  237. %    fi
  238. %  END
  239. %
  240.  
  241. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  242.  
  243. FUNCTION{init.state.consts}
  244. { 'before.all #0 :=
  245.   'mid.sentence #1 :=
  246.   'after.sentence #2 :=
  247.   'after.block #3 :=
  248. }
  249.  
  250. STRINGS { s t }            % temporary string holders
  251.  
  252. FUNCTION{output.nonnull}
  253. { 's swap$ :=
  254.   output.state mid.sentence =
  255.     { ", " * write$
  256.     }
  257.     { output.state after.block =
  258.     { add.period$ write$
  259.       newline$
  260.       "\newblock " write$
  261.     }
  262.     { output.state before.all =
  263.         { write$ }
  264.         { add.period$ " " * write$ }
  265.       if$
  266.     }
  267.       if$
  268.     }
  269.   if$
  270.   'output.state mid.sentence :=
  271.   s
  272. }
  273.  
  274. FUNCTION{output}
  275. { 's swap$ :=
  276.   s "" =
  277.     'skip$
  278.     { s output.nonnull
  279.     }
  280.   if$
  281. }
  282.  
  283. FUNCTION{output.check}
  284. { 's swap$ :=
  285.   't swap$ :=
  286.   s "" =
  287.     { "Warning: the " t * " shouldn't be empty in " * cite$ * top$
  288.     }
  289.     { s output.nonnull
  290.     }
  291.   if$
  292. }
  293.  
  294. FUNCTION{output.bibitem}
  295. { newline$
  296.   "\bibitem[" write$    % for nonnumeric labels,
  297.   label write$        % these three lines should be used
  298.   "]{" write$        % instead of the following line
  299. %  "\bibitem{" write$                - pfps
  300.   cite$ write$
  301.   "}" write$
  302.   newline$
  303.   ""
  304.   'output.state before.all :=
  305. }
  306.  
  307. % This function finishes all entries.  Note: For an otherwise empty entry
  308. % (which is probably due to a user error) this function prints a period
  309.  
  310. FUNCTION{fin.entry}
  311. { add.period$
  312.   write$
  313.   newline$
  314. }
  315.  
  316. FUNCTION{new.block}
  317. { output.state before.all =
  318.     'skip$
  319.     { 'output.state after.block := }
  320.   if$
  321. }
  322.  
  323. % This function isn't used in this style (plain)
  324.  
  325. FUNCTION{new.sentence}
  326. { output.state after.block =
  327.     'skip$
  328.     { output.state before.all =
  329.     'skip$
  330.     { 'output.state after.sentence := }
  331.       if$
  332.     }
  333.   if$
  334. }
  335.  
  336. % These three functions pop one or two (integer) arguments from the stack
  337. % and push a single one, either 0 or 1.
  338.  
  339. FUNCTION{not}
  340. {   { #0 }
  341.     { #1 }
  342.   if$
  343. }
  344.  
  345. FUNCTION{and}
  346. {   'skip$        % the corresponding if$ would be idempotent
  347.     { pop$ #0 }
  348.   if$
  349. }
  350.  
  351. FUNCTION{or}
  352. {   { pop$ #1 }
  353.     'skip$        % the corresponding if$ would be idempotent
  354.   if$
  355. }
  356.  
  357. % Here are some functions for formatting chunks of an entry.
  358. % By convention they either produce a string that can be followed by
  359. % a comma or period (using add.period$, so it is OK to end in a period),
  360. % or they produce the null string.
  361. %
  362. % A useful utility is the field.or.null function, which checks if the
  363. % argument is the result of pushing a `missing' field (one for which no
  364. % assignment was made when the current entry was read in from the database),
  365. % and returns the null string if so, otherwise it returns the field string.
  366. %
  367. % field.or.null(s) ==
  368. %  BEGIN
  369. %    if missing$(s) then return ""
  370. %    else return s
  371. %  END
  372. %
  373. % Another helper function is italicize, which returns the string that
  374. % italicizes the argument string, if that is non-null, otherwise it
  375. % returns the null string.  Italic corrections aren't used, so this
  376. % function should be used when punctation will follow the result.
  377. % Also, it needn't be \em (instead of \it) because the user shouldn't be
  378. % emphasizing the whole bibliography.
  379. %
  380. % italicize(s) ==
  381. %  BEGIN
  382. %    if s = "" then return ""
  383. %    else return "{\it " * s * "}"
  384. %
  385. % The format.names function formats the argument (which should be in
  386. % BibTeX name format) into "First Von Last, Junior", separated by commas
  387. % and with an "and" before the last.
  388. %
  389. % VAR: nameptr, namesleft, numnames: INTEGER
  390. %      nameresult: STRING
  391. %
  392. % format.names(s) ==
  393. %  BEGIN
  394. %    nameptr := 1
  395. %    nameresult := ""
  396. %    numnames := num.names$(s)
  397. %    namesleft := numnames
  398. %    while namesleft > 0
  399. %      do
  400. %        if nameptr > 1 then
  401. %        if namesleft > 0 then nameresult := nameresult * ", "
  402. %        else if numnames > 2
  403. %               then nameresult := nameresult * ", and "
  404. %               else nameresult := nameresult * " and "
  405. %             fi
  406. %        fi
  407. %        fi
  408. %        nameresult := nameresult *
  409. %        format.names$(s, nameptr, "{ff }{vv }{ll}{, jj}")
  410. %        nameptr := nameptr + 1
  411. %      od
  412. %    return nameresult
  413. %  END
  414. %
  415. % The format.authors function returns the result of format.names(author)
  416. % if the author is present, or else it returns the null string
  417. %
  418. % format.authors ==
  419. %  BEGIN
  420. %    if missing$(author) then return ""
  421. %    else return format.names(author)
  422. %    fi
  423. %  END
  424. %
  425. % Format.editors is like format.authors, but it uses the editor field,
  426. % and appends ", editor" or ", editors"
  427. %
  428. % format.editors ==
  429. %  BEGIN
  430. %    if missing$(editor) then return ""
  431. %    else
  432. %        if num.names$(editor) > 1 then
  433. %        return format.names(editor) * ", editors"
  434. %        else
  435. %        return format.names(editor) * ", editor"
  436. %        fi
  437. %    fi
  438. %  END
  439. %
  440. % Other formatting functions are similar, so no "comment version" will be
  441. % given for them.
  442.  
  443. FUNCTION{field.or.null}
  444. { duplicate$
  445.   missing$
  446.     { pop$    % a way to get the duplicate `missing' value off
  447.       ""
  448.     }
  449.     'skip$    % the duplicate is the return value
  450.   if$
  451. }
  452.  
  453. FUNCTION{italicize}
  454. { 's swap$ :=
  455.   s "" =
  456.     { "" }
  457.     { "{\it " s * "}" * }
  458.   if$
  459. }
  460.  
  461. INTEGERS{ nameptr namesleft numnames }
  462.  
  463. STRINGS{ nameresult }
  464.  
  465. FUNCTION{format.names}
  466. { 's swap$ :=
  467.   'nameptr #1 :=
  468.   'nameresult "" :=
  469.   'numnames s num.names$ :=
  470.   'namesleft numnames :=
  471.     { namesleft #0 > }
  472.     { 'namesleft namesleft #1 - :=
  473.       nameptr #1 >
  474.     { namesleft #0 >
  475.         { 'nameresult nameresult ", " * :=}
  476.         { numnames #2 >
  477.         { 'nameresult nameresult ", and " * :=}
  478.         { 'nameresult nameresult " and " * :=}
  479.           if$
  480.         }
  481.       if$
  482.     }
  483.     'skip$
  484.       if$
  485.       'nameresult
  486.       nameresult
  487.       s nameptr "{ff }{vv }{ll}{, jj}" format.name$
  488.       *
  489.     :=
  490.       'nameptr nameptr #1 +  :=
  491.     }
  492.   while$
  493.   nameresult    % return the result
  494. }
  495.  
  496. FUNCTION{format.authors}
  497. { author missing$
  498.     {""}
  499.     {author format.names}
  500.   if$
  501. }
  502.  
  503. FUNCTION{format.editors}
  504. { editor missing$
  505.     { ""
  506.     }
  507.     {
  508.       editor num.names$ #1 >
  509.     { editor format.names ", editors" * }
  510.     { editor format.names ", editor" * }
  511.       if$
  512.     }
  513.   if$
  514. }
  515.  
  516. % The format.title function is used for non-book-like titles.  We convert to
  517. % lowercase (except for the very first letter), and hope the user has
  518. % brace-surrounded words that need to stay capitilized.
  519.  
  520. FUNCTION{format.title}
  521. { title missing$
  522.     { "" }
  523.     { title "ul" change.case$ }
  524.   if$
  525. }
  526.  
  527. % The entry.string.max function is set to BibTeX's ent_str_size constant,
  528. % the maximum length of an entry string variable.
  529. %
  530. % The global.string.max function is set to BibTeX's glob_str_size constant,
  531. % the maximum length of a global string variable.
  532.  
  533. FUNCTION{entry.string.max} { #100 }
  534.  
  535. FUNCTION{global.string.max} { #300 }
  536.  
  537. % The n.dashify function makes each single `-' in a string a double `--'
  538. % if it's not already
  539. %
  540. % VAR: pageresult: STRING
  541. %
  542. % n.dashify(s) ==
  543. %  BEGIN
  544. %    t := s
  545. %    pageresult := ""
  546. %    while (not (t = ""))
  547. %      do
  548. %        if (first character of t = "-")
  549. %          then
  550. %        if (next character isn't)
  551. %          then
  552. %            pageresult := pageresult * "--"
  553. %            t := t with the "-" removed
  554. %          else
  555. %            while (first character of t = "-")
  556. %              do
  557. %            pageresult := pageresult * "-"
  558. %            t := t with the "-" removed
  559. %              od
  560. %        fi
  561. %          else
  562. %        pageresult := pageresult * the first character
  563. %        t := t with the first character removed
  564. %        fi
  565. %      od
  566. %    return pageresult
  567. %  END
  568.  
  569. STRINGS{ pageresult }
  570.  
  571. FUNCTION{n.dashify}
  572. { 't swap$ :=
  573.   'pageresult "" :=
  574.     { t "" = not }
  575.     { t #1 #1 substring$ "-" =
  576.     { t #1 #2 substring$ "--" = not
  577.         { 'pageresult pageresult "--" * :=
  578.           't t #2 global.string.max substring$ :=
  579.         }
  580.         {   { t #1 #1 substring$ "-" =}
  581.         { 'pageresult pageresult "-" * :=
  582.           't t #2 global.string.max substring$ :=
  583.         }
  584.           while$
  585.         }
  586.       if$
  587.     }
  588.     { 'pageresult pageresult t #1 #1 substring$ * :=
  589.       't t #2 global.string.max substring$ :=
  590.     }
  591.       if$
  592.     }
  593.   while$
  594.   pageresult
  595. }
  596.  
  597. % The format.vol.num.pages function is for the volume, number, and page range
  598. % of a journal article.  We use the format:  vol(number):pages
  599.  
  600. FUNCTION{format.vol.num.pages}
  601. { volume field.or.null
  602.   number missing$
  603.     { booktitle missing$
  604.         { "" }
  605.     { "(" booktitle * ")" * }
  606.       if$
  607.     }
  608.     { "(" number *
  609.       booktitle missing$
  610.         { "" }
  611.     { ", " booktitle * }
  612.       if$
  613.       * ")" *
  614.     }
  615.   if$
  616.   *
  617.   pages missing$
  618.     { "" }
  619.     { ":" pages n.dashify * }
  620.   if$
  621.   *
  622. }
  623.  
  624. % The format.date function is for the month and year, but we give a warning if
  625. % there's a missing year but the month is there, and we return the empty string
  626. % if they're both missing
  627.  
  628. FUNCTION{format.date}
  629. { year missing$
  630.     { month missing$
  631.     { "" }
  632.     { "Warning: there's a month but no year in " cite$ * top$
  633.       month
  634.     }
  635.       if$
  636.     }
  637.     { month missing$
  638.     { year }
  639.     { month " " * year * }
  640.       if$
  641.     }
  642.   if$
  643. }
  644.  
  645. % The format.btitle is for formatting the title field when it is a book-like
  646. % entry---the style used here keeps it in uppers-and-lowers and italicizes it.
  647.  
  648. FUNCTION{format.btitle}
  649. { title field.or.null
  650.   italicize
  651. }
  652.  
  653. % The format.bvolume function is for formatting the volume number and/or
  654. % series name of a multivolume book.  If the volume field is missing, we
  655. % output either the series field italicized if it exists or the null string
  656. % otherwise.  If both the volume and series fields are there, we assume the
  657. % series field is the title of the whole multivolume work (the title field
  658. % should be the title of the one referred to), and add an "of <series>".
  659. % A tie (~) is put between the "Volume" and the volume number.
  660. % We capitilize Volume because this function is used at the beginning of a
  661. % block.
  662.  
  663. FUNCTION{format.bvolume}
  664. { volume missing$
  665.     { series missing$
  666.     { "" }
  667.     { series italicize }
  668.       if$
  669.     }
  670.     { "Volume~" volume *
  671.       series missing$
  672.     'skip$
  673.     { " of " * series italicize * }
  674.       if$
  675.     }
  676.   if$
  677. }
  678.  
  679. % The format.edition function appends " edition" to the edition, if present.
  680. % We lowercase the edition (it should be something like "Third"), because
  681. % this doesn't start a sentence.
  682.  
  683. FUNCTION{format.edition}
  684. { edition missing$
  685.     { "" }
  686.     { edition "ll" change.case$ " edition" * }
  687.   if$
  688. }
  689.  
  690. % The format.pages function is used for formatting a page range in a book.
  691. % The multi.page.check function examines the page field for a "-" or a ","
  692. % so that format.pages can use "page" instead of "pages" if neither exists.
  693. % Note: global.string.max, set above, here means "take the rest of the string"
  694. %
  695. % VAR: multiresult: INTEGER    (actually, a boolean)
  696. %
  697. % multi.page.check(s) ==
  698. %  BEGIN
  699. %    t := s
  700. %    multiresult := false
  701. %    while ((not multiresult) and (not (t = "")))
  702. %      do
  703. %        if (first character of t = "-" or ",")
  704. %          then multiresult := true
  705. %          else t := t with the first character removed
  706. %        fi
  707. %      od
  708. %    return multiresult
  709. %  END
  710.  
  711. INTEGERS{ multiresult }
  712.  
  713. FUNCTION{multi.page.check}
  714. { 't swap$ :=
  715.   'multiresult #0 :=
  716.     { multiresult not
  717.       t "" = not
  718.       and
  719.     }
  720.     { t #1 #1 substring$ "-" =
  721.       t #1 #1 substring$ "," =
  722.       or
  723.     { 'multiresult #1 := }
  724.     { 't t #2 global.string.max substring$ := }
  725.       if$
  726.     }
  727.   while$
  728.   multiresult
  729. }
  730.  
  731. FUNCTION{format.pages}
  732. { pages missing$
  733.     { "" }
  734.     { pages multi.page.check
  735.     { "pages~" pages n.dashify * }
  736.     { "page~" pages n.dashify * }
  737.       if$
  738.     }
  739.   if$
  740. }
  741.  
  742. % The format.chapter.pages puts "chapter~" in front of a chapter number,
  743. % if present, and then appends the pages, if present.
  744. % This doesn't begin a sentence.
  745.  
  746. FUNCTION{format.chapter.pages}
  747. { chapter missing$
  748.     { format.pages }
  749.     { "chapter~" chapter *
  750.       pages missing$
  751.     'skip$
  752.     { ", " * format.pages * }
  753.       if$
  754.     }
  755.   if$
  756. }
  757.  
  758. % The format.in.ed.booktitle function is used for starting out a sentence
  759. % that begins "In <booktitle>", putting an editor before the title if one
  760. % exists.
  761.  
  762. FUNCTION{format.in.ed.booktitle}
  763. { booktitle missing$
  764.     { ""
  765.     }
  766.     { 's format.editors :=
  767.       s "" =
  768.     { "In " booktitle italicize * }
  769.     { "In " s * ", " * booktitle italicize * }
  770.       if$
  771.     }
  772.   if$
  773. }
  774.  
  775. % The format.in.techreport function is used for starting out a sentence
  776. % that begins "In <techreport>"
  777.  
  778. FUNCTION{format.in.techreport}
  779. { booktitle missing$
  780.     { "" }
  781.     { "In " booktitle * }
  782.   if$
  783. }
  784.  
  785. % The format.tr.number makes a string starting with "Technical Report"
  786. % (or type, if that field is defined), followed by the number if there
  787. % is one (but return the first part even if there is no number)
  788.  
  789. FUNCTION{format.tr.number}
  790. { type missing$
  791.     { "Technical Report" }
  792.     { type }
  793.   if$
  794.   number missing$
  795.     'skip$
  796.     { "~" * number * }
  797.   if$
  798. }
  799.  
  800. % Now we define the type functions for all entry types that may appear
  801. % in the .BIB file -- e.g., functions like `book' and `article'.  These
  802. % are the routines that actually generate the .BBL file output for
  803. % the entry.  In addition, the style designer should have a function
  804. % `default.type' for unknown types.  Note: The fields (within each list)
  805. % are listed in order of appearance.
  806. %
  807. % The article function is for an article in a journal.
  808. %    Required fields: author, title, journal, year
  809. %    Optional fields: volume, number, pages, month, note
  810. %
  811. % article ==
  812. %  BEGIN
  813. %    output.bibitem
  814. %    output.check("author",format.authors)
  815. %    new.block
  816. %    output.check("title",format.title)
  817. %    new.block
  818. %    output.check("journal",italicize(field.or.null(journal)))
  819. %    output(format.vol.num.pages)
  820. %    output.check("year",format.date)
  821. %    new.block
  822. %    output(field.or.null(note))
  823. %    fin.entry
  824. %  END
  825. %
  826. % The book function is for a whole book.
  827. %    Required fields: author or editor, title, publisher, year
  828. %    Optional fields: volume, series, address, edition, month, note
  829. %
  830. % book ==
  831. %  BEGIN
  832. %    if missing$(author) then output.check("author and editor",
  833. %                                format.editors)
  834. %    else output.check("author",format.authors)
  835. %    fi
  836. %    new.block
  837. %    output.check("title",format.btitle)
  838. %    new.block
  839. %    output(format.bvolume)
  840. %    output.check("publisher",field.or.null(publisher))
  841. %    output(field.or.null(address))
  842. %    output(format.edition)
  843. %    output.check("year",format.date))
  844. %    new.block
  845. %    output(field.or.null(note))
  846. %    fin.entry
  847. %  END
  848. %
  849. % The other entry functions are all quite similar, so no "comment version"
  850. % will be given for them.
  851.  
  852. FUNCTION{article}
  853. { output.bibitem
  854.   "author" format.authors output.check
  855.   new.block
  856.   "title" format.title output.check
  857.   new.block
  858.   "journal" journal field.or.null italicize output.check
  859.   format.vol.num.pages output
  860.   "year" format.date output.check
  861.   new.block
  862.   note field.or.null output
  863.   fin.entry
  864. }
  865.  
  866. FUNCTION{book}
  867. { output.bibitem
  868.   author missing$
  869.     { "author and editor" format.editors output.check
  870.     }
  871.     { "author" format.authors output.check
  872.     }
  873.   if$
  874.   new.block
  875.   "title" format.btitle output.check
  876.   new.block
  877.   format.bvolume output
  878.   "publisher" publisher field.or.null output.check
  879.   address field.or.null output
  880.   format.edition output
  881.   "year" format.date output.check
  882.   new.block
  883.   note field.or.null output
  884.   fin.entry
  885. }
  886.  
  887. % The booklet function is for bound things without publishers or
  888. % sponsoring institutions
  889. %    Required: title
  890. %    Optional: author, howpublished, address, month, year, note
  891.  
  892. FUNCTION{booklet}
  893. { output.bibitem
  894.   format.authors output
  895.   new.block
  896.   "title" format.btitle output.check
  897.   new.block
  898.   howpublished field.or.null output
  899.   address field.or.null output
  900.   format.date output
  901.   new.block
  902.   note field.or.null output
  903.   fin.entry
  904. }
  905.  
  906. % For the conference entry type, see inproceedings
  907.  
  908. % An inbook is a piece of a book: either a chapter or a page range.
  909. %    Required: author or editor, title, chapter or pages, publisher, year
  910. %    Optional: volume, series, address, edition, month, note
  911.  
  912. FUNCTION{inbook}
  913. { output.bibitem
  914.   author missing$
  915.     { "author and editor" format.editors output.check
  916.     }
  917.     { "author" format.authors output.check
  918.     }
  919.   if$
  920.   new.block
  921.   "title" format.btitle output.check
  922.   "chapter and pages" format.chapter.pages output.check
  923.   new.block
  924.   format.bvolume output
  925.   "publisher" publisher field.or.null output.check
  926.   address field.or.null output
  927.   format.edition output
  928.   "year" format.date output.check
  929.   new.block
  930.   note field.or.null output
  931.   fin.entry
  932. }
  933.  
  934. % An incollection is like inbook, but where there is a separate title
  935. % for the referenced thing (and perhaps an editor for the whole)
  936. %    Required: author, title, booktitle, publisher, year
  937. %    Optional: editor, chapter, pages, address, month, note
  938.  
  939. FUNCTION{incollection}
  940. { output.bibitem
  941.   "authors" format.authors output.check
  942.   new.block
  943.   "title" format.title output.check
  944.   new.block
  945.   "booktitle" format.in.ed.booktitle output.check
  946.   format.chapter.pages output
  947.   "publisher" publisher field.or.null output.check
  948.   address field.or.null output
  949.   "year" format.date output.check
  950.   new.block
  951.   note field.or.null output
  952.   fin.entry
  953. }
  954.  
  955. % An intechreport is almost the same as an incollection
  956. FUNCTION{intechreport}
  957. { output.bibitem
  958.   "authors" format.authors output.check
  959.   new.block
  960.   "title" format.title output.check
  961.   new.block
  962.   "booktitle" format.in.techreport output.check
  963.   format.chapter.pages output
  964.   format.tr.number output
  965.   "insitution" institution field.or.null output.check
  966.   address field.or.null output
  967.   "year" format.date output.check
  968.   new.block
  969.   note field.or.null output
  970.   fin.entry
  971. }
  972.  
  973. % An inproceedings is an article in a conference proceedings
  974. %    Required: author, title, booktitle, year
  975. %    Optional: editor, pages, organization, publisher, address,
  976. %          month, note, location
  977.  
  978. FUNCTION{inproceedings}
  979. { output.bibitem
  980.   "author" format.authors output.check
  981.   new.block
  982.   "title" format.title output.check
  983.   new.block
  984.   "booktitle" format.in.ed.booktitle output.check
  985.   format.pages output
  986.   location field.or.null output
  987.   organization field.or.null output
  988.   publisher field.or.null output
  989.   address field.or.null output
  990.   "year" format.date output.check
  991.   new.block
  992.   note field.or.null output
  993.   fin.entry
  994. }
  995.  
  996. % The conference function is included for Scribe compatibility
  997.  
  998. FUNCTION{conference} {inproceedings}
  999.  
  1000. % A manual is technical documentation
  1001. %    Required: title
  1002. %    Optional: author, organization, address, edition, month, year, note
  1003.  
  1004. FUNCTION{manual}
  1005. { output.bibitem
  1006.   format.authors output
  1007.   new.block
  1008.   "title" format.btitle output.check
  1009.   new.block
  1010.   organization field.or.null output
  1011.   address field.or.null output
  1012.   format.edition output
  1013.   format.date output
  1014.   new.block
  1015.   note field.or.null output
  1016.   fin.entry
  1017. }
  1018.  
  1019. % A mastersthesis is a Master's thesis
  1020. %    Required: author, title, school, year
  1021. %    Optional: address, month, note
  1022.  
  1023. FUNCTION{mastersthesis}
  1024. { output.bibitem
  1025.   "author" format.authors output.check
  1026.   new.block
  1027.   "title" format.btitle output.check
  1028.   new.block
  1029.   "Master's thesis" output
  1030.   "school" school field.or.null output.check
  1031.   address field.or.null output
  1032.   "year" format.date output.check
  1033.   new.block
  1034.   note field.or.null output
  1035.   fin.entry
  1036. }
  1037.  
  1038. % a misc is something that doesn't fit elsewhere
  1039. %    Required: none
  1040. %    Optional: author, title, howpublished, month, year, note
  1041.  
  1042. FUNCTION{misc}
  1043. { output.bibitem
  1044.   format.authors output
  1045.   new.block
  1046.   format.title output
  1047.   new.block
  1048.   howpublished field.or.null output
  1049.   format.date output
  1050.   new.block
  1051.   note field.or.null output
  1052.   fin.entry
  1053. }
  1054.  
  1055. % A phdthesis is like a mastersthesis
  1056. %    Required: author, title, school, year
  1057. %    Optional: address, month, note
  1058.  
  1059. FUNCTION{phdthesis}
  1060. { output.bibitem
  1061.   "author" format.authors output.check
  1062.   new.block
  1063.   "title" format.btitle output.check
  1064.   new.block
  1065.   "PhD thesis" output
  1066.   "school" school field.or.null output.check
  1067.   address field.or.null output
  1068.   "year" format.date output.check
  1069.   new.block
  1070.   note field.or.null output
  1071.   fin.entry
  1072. }
  1073.  
  1074. % a proceedings is a conference proceedings
  1075. %    Required: editor or organization, title, year
  1076. %    Optional: publisher, address, month, note
  1077.  
  1078. FUNCTION{proceedings}
  1079. { output.bibitem
  1080.   editor missing$
  1081.     { "editor and organization" organization field.or.null output.check
  1082.     }
  1083.     { "editor" format.editors output.check
  1084.     }
  1085.   if$
  1086.   new.block
  1087.   "title" format.btitle output.check
  1088.   publisher field.or.null output
  1089.   address field.or.null output
  1090.   "year" format.date output.check
  1091.   new.block
  1092.   note field.or.null output
  1093.   fin.entry
  1094. }
  1095.  
  1096. % a techreport is a technical report.
  1097. %    Required: author, title, institution, year
  1098. %    Optional: type, number, address, month, note
  1099.  
  1100. FUNCTION{techreport}
  1101. { output.bibitem
  1102.   "author" format.authors output.check
  1103.   new.block
  1104.   "title" format.btitle output.check
  1105.   new.block
  1106.   format.tr.number output
  1107.   "institution" institution field.or.null output.check
  1108.   address field.or.null output
  1109.   "year" format.date output.check
  1110.   new.block
  1111.   note field.or.null output
  1112.   fin.entry
  1113. }
  1114.  
  1115. % an unpublished is something that hasn't been published
  1116. %    Required: author, title, note
  1117. %    Optional: month, year
  1118.  
  1119. FUNCTION{unpublished}
  1120. { output.bibitem
  1121.   "author" format.authors output.check
  1122.   new.block
  1123.   "title" format.title output.check
  1124.   new.block
  1125.   format.date output
  1126.   new.block
  1127.   "note" note field.or.null output.check
  1128.   fin.entry
  1129. }
  1130.  
  1131. % We use entry type book for an unknown type and give a warning
  1132.  
  1133. FUNCTION{default.type} {book}
  1134.  
  1135. % Here are macros for common things that may vary from style to style.
  1136. % Users are encouraged to use these macros.
  1137.  
  1138. % For this style (plain), months and journals are written out in full
  1139.  
  1140. MACRO{jan} {"January"}
  1141.  
  1142. MACRO{feb} {"February"}
  1143.  
  1144. MACRO{mar} {"March"}
  1145.  
  1146. MACRO{apr} {"April"}
  1147.  
  1148. MACRO{may} {"May"}
  1149.  
  1150. MACRO{jun} {"June"}
  1151.  
  1152. MACRO{jul} {"July"}
  1153.  
  1154. MACRO{aug} {"August"}
  1155.  
  1156. MACRO{sep} {"September"}
  1157.  
  1158. MACRO{oct} {"October"}
  1159.  
  1160. MACRO{nov} {"November"}
  1161.  
  1162. MACRO{dec} {"December"}
  1163.  
  1164. MACRO{acmcs} {"ACM Computing Surveys"}
  1165.  
  1166. MACRO{acta} {"Acta Informatica"}
  1167.  
  1168. MACRO{cacm} {"Communications of the ACM"}
  1169.  
  1170. MACRO{ibmjrd} {"IBM Journal of Research and Development"}
  1171.  
  1172. MACRO{ibmsj} {"IBM Systems Journal"}
  1173.  
  1174. MACRO{ieeese} {"IEEE Transactions on Software Engineering"}
  1175.  
  1176. MACRO{ieeetc} {"IEEE Transactions on Computers"}
  1177.  
  1178. MACRO{ieeetcad}
  1179.  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  1180.  
  1181. MACRO{ipl} {"Information Processing Letters"}
  1182.  
  1183. MACRO{jacm} {"Journal of the ACM"}
  1184.  
  1185. MACRO{jcss} {"Journal of Computer and System Sciences"}
  1186.  
  1187. MACRO{scp} {"Science of Computer Programming"}
  1188.  
  1189. MACRO{sicomp} {"SIAM Journal on Computing"}
  1190.  
  1191. MACRO{tocs} {"ACM Transactions on Computer Systems"}
  1192.  
  1193. MACRO{tods} {"ACM Transactions on Database Systems"}
  1194.  
  1195. MACRO{tog} {"ACM Transactions on Graphics"}
  1196.  
  1197. MACRO{toms} {"ACM Transactions on Mathematical Software"}
  1198.  
  1199. MACRO{toois} {"ACM Transactions on Office Information Systems"}
  1200.  
  1201. MACRO{toplas} {"ACM Transactions on Programming Languages and Systems"}
  1202.  
  1203. MACRO{tsc} {"Theoretical Computer Science"}
  1204.  
  1205. % Now we read in the .BIB entries.
  1206.  
  1207. READ
  1208.  
  1209. % I CHANGED THIS SORTKEY TO BE BETTER - pfps
  1210. % Next we compute the sortkey by executing "presort" on each entry.
  1211. % The presort key contains a number of purified strings, concatenated
  1212. % with multiple blanks between them.  Since purify$ makes sure there will
  1213. % not be consecutive multiple blanks in its result, this makes things
  1214. % like "John  Jones" come before "John Green  Brown".
  1215. %
  1216. % The fields used here are: the author names (or editor names, if those
  1217. % are missing, or the key field if both are), WITH THE NUMBER OF NAMES
  1218. % HERE AFTER THE FIRST NAME, FOLLOWED BY THE YEAR, followed by the first bit
  1219. % of the title (chopping off a leading "The", "A", or "An").
  1220. % Names are formatted: Von Last First Junior, with the First names
  1221. % abbreviated.  Two blanks will separate the name parts (except the von
  1222. % and last), three will separate the names, and four will separate the
  1223. % names from the YEAR AND THE YEAR FROM THE title.
  1224.  
  1225. % The sort.format.names function takes an argument that should be in
  1226. % BibTeX name format, and returns a string containing "   "-separated
  1227. % names in the format described above.  The function is almost the same
  1228. % as format.names.
  1229.  
  1230. FUNCTION{sort.format.names}
  1231. { 's swap$ :=
  1232.   'nameptr #1 :=
  1233.   'nameresult "" :=
  1234.   'namesleft s num.names$ :=
  1235.     { namesleft #0 > }
  1236.     { 'namesleft namesleft #1 - :=
  1237.       nameptr #1 >
  1238.     { 'nameresult nameresult "   " * := }
  1239.     'skip$
  1240.       if$
  1241.       'nameresult
  1242.       nameresult
  1243.       s nameptr "{vv }{ll}{  f}{  jj}" format.name$
  1244.         "ll" change.case$
  1245.       purify$
  1246.       *
  1247.     :=
  1248.        nameptr #1 =
  1249.          { 'nameresult
  1250.         nameresult "   " * namesleft #1 + int.to.str$ *
  1251.        := }
  1252.      'skip$
  1253.        if$
  1254.       'nameptr nameptr #1 +  :=
  1255.     }
  1256.   while$
  1257.   nameresult    % return the result
  1258. }
  1259.  
  1260. % The chop.word(w,len,s) function returns either s or, if the first len
  1261. % letters of s equals w, it returns that part of s after w.
  1262.  
  1263. INTEGERS { len }
  1264.  
  1265. FUNCTION{chop.word}
  1266. { 's swap$ :=
  1267.   'len swap$ :=
  1268.   s #1 len substring$ =        % comparing against w, on the stack
  1269.     { s len #1 + global.string.max substring$ }
  1270.     { s }
  1271.   if$
  1272. }
  1273.  
  1274. % The sort.format.title function returns the the argument,
  1275. % but first any leading "A "'s, "An "'s, or "The "'s are removed.
  1276. % The chop.word function uses s, so we need another string variable, t
  1277.  
  1278. FUNCTION{sort.format.title}
  1279. { 't swap$ :=
  1280.   "A " #2
  1281.     "An " #3
  1282.       "The " #4 t chop.word
  1283.     chop.word
  1284.   chop.word
  1285.   #1 global.string.max substring$
  1286.   purify$
  1287. }
  1288.  
  1289. % There is a limit on the length of an entry string variable, which
  1290. % is what its sort.key$ is.  The limit is currently entry.string.max, so we
  1291. % take at most that many characters of the constructed key, and hope
  1292. % there aren't many references that match to that many characters!
  1293.  
  1294. FUNCTION{presort}
  1295. { author missing$
  1296.     { editor missing$
  1297.     { key field.or.null }
  1298.     { editor sort.format.names }
  1299.       if$
  1300.     }
  1301.     { author sort.format.names }
  1302.   if$
  1303.   "    "
  1304.   *
  1305.   year field.or.null
  1306.   *
  1307.   "    "
  1308.   *
  1309.   title field.or.null
  1310.   sort.format.title
  1311.   *
  1312.   #1 entry.string.max substring$
  1313.   'sort.key$ swap$ :=
  1314. }
  1315.  
  1316. ITERATE{presort}
  1317.  
  1318. % And now we can sort
  1319. %
  1320. % To get the unsorted style (plainu) from this one (plain), it suffices
  1321. % to simply comment out the ITERATE{presort} and SORT commands
  1322.  
  1323. SORT
  1324.  
  1325. %%I CHANGED THIS PART - pfps 
  1326. %% Now comes the computation of the label.  We use numbers, in the sort order.
  1327. %% We have to keep track of the longest (in width$ terms) label, for use
  1328. %% by the "thebibliography" environment.
  1329. %%
  1330. %% For nonnumeric labels, this computation is more complicated.
  1331. %
  1332. %STRINGS{longest.label}
  1333. %
  1334. %INTEGERS{number.label longest.label.width}
  1335. %
  1336. %FUNCTION{initialize.labels}
  1337. %{ 'longest.label "" :=
  1338. %  'number.label #1  :=
  1339. %  'longest.label.width #0 :=
  1340. %}
  1341. %
  1342. %FUNCTION{forward.pass}
  1343. %{ 'label number.label int.to.str$ :=
  1344. %  'number.label number.label #1 + :=
  1345. %  label width$ longest.label.width >
  1346. %    { 'longest.label label :=
  1347. %      'longest.label.width label width$ :=
  1348. %    }
  1349. %    'skip$
  1350. %  if$
  1351. %}
  1352. %
  1353. %EXECUTE{initialize.labels}
  1354. %
  1355. %ITERATE{forward.pass}
  1356. %
  1357. %% Note:  When using nonnumeric labels, the forward.pass must compute those
  1358. %% labels as well as the `b', `c', `d' etc. that will be appended to otherwise
  1359. %% identical labels.  There should then also be a reverse.pass to compute
  1360. %% the `a', do whatever appending needs done, and compute the longest label
  1361. %% (forward.pass can't compute this).
  1362. %
  1363. %% REVERSE{reverse.pass}
  1364. %
  1365. %Now comes the computation of the label.  We use the authors' names,
  1366. %followed by the year of publication, followed by a distinguisher 'a'
  1367. %etc. if necessary.  This has been modified from sample.bst. - pfps
  1368. % Now we finish the computation of each entry's label, putting in
  1369. % the 'a's and 'b's and so forth if required.  This involves two
  1370. % passes: a forward pass to put in the 'b's, 'c's and so on, and 
  1371. % a backwards pass to put in the 'a's.  The second pass also puts
  1372. % the longest label into the variable longestlabel
  1373. %
  1374. % VARS: longest.label, last.label : string
  1375. %       label.width, last.extra   : integer
  1376. %
  1377. % label.format ==
  1378. %  BEGIN
  1379. %    numnames := num.names$(author)
  1380. %       if missing$(author) then label := ""
  1381. %       else if numnames = 1 
  1382. %         then label := format.names$(author,1,"{vv }{ll}")
  1383. %         else if numnames = 2
  1384. %          then label := format.names$(author,1,"{vv }{ll and }") *
  1385. %                format.names$(author,2,"{vv }{ll}")
  1386. %                 else label := format.names$(author,1,"{vv }{ll {\em et al.}}")
  1387. %          fi
  1388. %            fi
  1389. %       fi
  1390. %    if missing$(year) then return label
  1391. %    else return "\protect\citename{" * label * ", }" * year % pfps 9/86
  1392. %  END
  1393. %
  1394. % initialize.labels ==
  1395. %  BEGIN
  1396. %     longest.label := last.label := next.extra := null
  1397. %     label.width   := last.extra := 0
  1398. %  END
  1399. %
  1400. % forward.pass ==
  1401. %  BEGIN
  1402. %   label := label.format()
  1403. %   FPIF: if last.label = label
  1404. %           then last.extra := last.extra + 1
  1405. %                extralabel := ascii$(`a + last.extra)
  1406. %           else last.extra := 0
  1407. %                extralabel := null
  1408. %         fi
  1409. %  END
  1410. %
  1411. % reverse.pass ==
  1412. %  BEGIN
  1413. %     if next.extra = "b"
  1414. %             then extralabel := "a"
  1415. %           fi
  1416. %           label := label * extralabel
  1417. %%    if width${label} > label.width
  1418. %%             then longest.label := label
  1419. %%                  label.width := width${label}
  1420. %%           fi
  1421. %           next.extra := extralabel
  1422. %  END
  1423.  
  1424. STRINGS{last.label next.extra}
  1425. INTEGERS{last.extra}
  1426.  
  1427. FUNCTION{initialize.labels}
  1428. { 'last.label ""    :=
  1429.   'next.extra ""    :=
  1430.   'last.extra  #0    :=
  1431. %  'label.width #0    :=
  1432. %  'longest.label "" :=
  1433. }
  1434.  
  1435. FUNCTION{label.format.names}
  1436. { 's swap$ :=
  1437.   'numnames s num.names$ :=
  1438.   numnames #1 =
  1439.     { 's s #1 "{vv }{ll}" format.name$ := }
  1440.     { numnames #2 =
  1441.         { 's s #1 "{vv }{ll }and " format.name$
  1442.          s #2 "{vv }{ll}" format.name$ * :=
  1443.         }
  1444.         { 's s #1 "{vv }{ll }\bgroup \em et al.\egroup " format.name$ := }
  1445.       if$
  1446.     }
  1447.   if$
  1448.   s
  1449. }
  1450.  
  1451. FUNCTION{label.format}
  1452. { author missing$
  1453.     { editor missing$
  1454.         { 'label "" := }
  1455.     { 'label editor label.format.names := }
  1456.       if$
  1457.     }
  1458.     { 'label author label.format.names := }
  1459.   if$
  1460.   year missing$
  1461.     { label } % pfps 9/86
  1462.     { label "" = 
  1463.       {""} 
  1464.       {"\protect\citename{" label * ", }" *}  % pfps 9/86
  1465.       if$ 
  1466.       year * }
  1467.   if$
  1468. }
  1469.  
  1470. FUNCTION{forward.pass}
  1471. { 'label label.format :=
  1472.   label last.label = 
  1473.     { 'last.extra last.extra #1 +  := 
  1474.       'extralabel  #97 last.extra + int.to.chr$ :=
  1475.     }
  1476.     { 'last.extra #0 :=
  1477.       'extralabel "" :=
  1478.     }
  1479.   if$
  1480.   'last.label label :=
  1481. }
  1482.  
  1483. FUNCTION{reverse.pass}
  1484. { next.extra "b" = 
  1485.     { 'extralabel "a" :=}
  1486.     'skip$
  1487.   if$
  1488.   'label label extralabel * :=
  1489.   'next.extra extralabel :=
  1490. %  label.width label width$ > 
  1491. %    'skip$
  1492. %    { 'longest.label label :=
  1493. %      'label.width  label width$    :=
  1494. %    }
  1495. %  if$
  1496. }
  1497.  
  1498. EXECUTE{initialize.labels}
  1499. ITERATE{forward.pass}
  1500. REVERSE{reverse.pass}
  1501.  
  1502.  
  1503.  
  1504. % Now we're ready to start writing the .BBL file.  First we write
  1505. % the `preamble' containing the command
  1506. %     \begin{thebibliography}{...}
  1507. % where the `...' is the longest label.
  1508. % Also, we call init.state.consts, for use by the output routines.
  1509. %
  1510. % The following \sfcode declaration causes a `.' (period) not to
  1511. % produce an end-of-sentence space.  Each entry is divided into
  1512. % `blocks', which are separated by a \newblock command.  The following
  1513. % \def command defines \newblock to add horizontal space, giving
  1514. % a `closed' format.
  1515. %    \def\newblock{\hskip .11em plus .33em minus -.07em}
  1516. %    \sfcode`\.=1000\relax
  1517. %
  1518. % For an `open' format (each block on a new line), replace these commands by:
  1519. %    \def\newblock{\\\relax}
  1520.  
  1521. FUNCTION{preamble}
  1522. { init.state.consts
  1523.   "\begin{thebibliography}{"  "xx" % longest.label
  1524.                   * "}" * write$
  1525.   newline$
  1526.   "% The newblock command here creates a `closed' format" write$
  1527.   newline$
  1528.   "% and the sfcode command affects the spacing after a period;" write$
  1529.   newline$
  1530.   "% for more details please ask a style designer." write$
  1531.   newline$
  1532.   "\def\newblock{\hskip .11em plus .33em minus -.07em}" write$
  1533.   "\sfcode`\.=1000\relax" write$
  1534.   newline$
  1535. }
  1536.  
  1537. EXECUTE{preamble}
  1538.  
  1539. % Now we execute to produce the output for all the entries
  1540.  
  1541. ITERATE{call.type$}
  1542.  
  1543. % Finally, we finish up by writing the `\end{thebibliography}' command.
  1544.  
  1545. FUNCTION{finish.up}{ newline$ "\end{thebibliography}" write$ newline$}
  1546.  
  1547. EXECUTE{finish.up}
  1548.